import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

class Employee implements Comparable<Employee>{
    private String name;
    private double salary;
    // 比较者大于被比较者，返回正数。小于，返回-1，等于0

    public Employee() {
    }

    public Employee(String name, double salary) {

        this.name = name;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public int compareTo(Employee o) {
        return (int)(this.salary-o.salary);
    }
}
public class test {
    public static void main(String[] args) {
        Set<Employee> employeeSet = new TreeSet<>(new Comparator<Employee>() {
            @Override
            public int compare(Employee o1, Employee o2) {
                return (int) (o1.getSalary()-o2.getSalary());
            }
        });

    }
}
